#ifndef TRACKSCENE_H
#define TRACKSCENE_H

#include <QGraphicsScene>
#include <QList>
#include "tracksegment.h"
#include "maglevvehicle.h"

class TrackScene : public QGraphicsScene
{
    Q_OBJECT

public:
    TrackScene(QObject* parent = nullptr);
    
    void addTrackSegment(TrackSegment* segment);
    void removeTrackSegment(TrackSegment* segment);
    QList<TrackSegment*> trackSegments() const;
    
    void addVehicle(MaglevVehicle* vehicle);
    void removeVehicle(MaglevVehicle* vehicle);
    QList<MaglevVehicle*> vehicles() const;
    
    TrackSegment* getTrackSegmentAt(const QPointF& pos) const;
    QPointF snapToTrack(const QPointF& pos) const;
    
    void updateTrackConnections();
    
protected:
    void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
    void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
    void dropEvent(QGraphicsSceneDragDropEvent* event) override;
    
private:
    QList<TrackSegment*> m_trackSegments;
    QList<MaglevVehicle*> m_vehicles;
};

#endif // TRACKSCENE_H
